package com.liulu.tools

import android.content.Context
import android.content.res.Resources

private val resources = Resources.getSystem()

/**
 * 状态栏高度
 *
 * @return
 */
fun getStatusBarHeight(): Int {
    return getStatusBarHeight(40.dp2px)
}

/**
 * 状态栏高度
 *
 * @param px 默认高度
 * @return
 */
fun getStatusBarHeight(px: Int = 40.dp2px): Int {
    val resourceId = resources.getIdentifier("status_bar_height", "dimen", "android")
    return if (resourceId > 0) {
        resources.getDimensionPixelSize(resourceId)
    } else {
        px
    }
}

/**
 * 导航栏高度
 *
 * @return
 */
fun getNavigationBarHeight(): Int {
    val resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android")
    return if (resourceId > 0) {
        resources.getDimensionPixelSize(resourceId)
    } else {
        0
    }
}